#ifndef XGE_Allocator_H_
#define XGE_Allocator_H_
#include <malloc.h>

#ifdef _DEBUG
#pragma comment(lib,"../ned_alloc/Debug/ned_alloc.lib")
#else
#pragma comment(lib,"../ned_alloc/Release/ned_alloc.lib")
#endif

namespace xge {
namespace xge_internal {
  // basic malloc routine for using 
  void* XMalloc ( size_t size );
  void  XFree   ( void* ptr   );
  void* XRealloc( void* ptr , size_t size );
}

  // We will use XMalloc , XFree , XRealloc ONLY in
  // release version , since using the original malloc and free
  // will help us take advantage of CrtDbg helper function to
  // detect memory leak .

  class Allocator{
  public:

    static void* operator new( size_t size ) {
#ifndef _DEBUG
      return xge_internal::XMalloc(size);
#else
      return malloc(size);
#endif
    }
    static void* operator new[]( size_t size ) {
#ifndef _DEBUG
      return xge_internal::XMalloc(size);
#else
      return malloc(size);
#endif
    }
    static void operator delete( void* ptr ) {
#ifndef _DEBUG
      xge_internal::XFree(ptr);
#else
      free(ptr);
#endif
    }
    static void operator delete[]( void* ptr ) {
#ifndef _DEBUG
      xge_internal::XFree(ptr);
#else
      free(ptr);
#endif
    }
  };
} // xge
#endif // XGE_Allocator_H_